[FLINK-39984][runtime][webUI] Support LITE/FULL thread dump modes - #28732
[FLINK-39984][runtime][webUI] Support LITE/FULL thread dump modes#28732xingsuo-zbz wants to merge 1 commit into
Conversation
|
A few minor comments before the review:
|
bc6b4a8 to
36f9795
Compare
|
@flinkbot run azure |
|
@spuru9 done,please continue to review |
Myasuka
left a comment
There was a problem hiding this comment.
I think we should split this PR into two PRs, one is to use ioExecutor instead of main thread; one is to introduce new feature that we can have options to select when creating thread dumps.
36f9795 to
117a668
Compare
117a668 to
86388ac
Compare
86388ac to
a12f903
Compare
|
@flinkbot run azure |
a12f903 to
ebafa89
Compare
|
@xingsuo-zbz Please rebase code after #28778 merged. |
ebafa89 to
be8a20c
Compare
ThreadMXBean.dumpAllThreads(true, true) enters a single JVM-wide
safepoint to collect monitor/synchronizer state; on busy JVMs the pause
can exceed heartbeat.timeout and cause unnecessary TaskManager failover.
- Introduce ThreadDumpMode {LITE, FULL}: LITE = dumpAllThreads(false,
false), FULL preserves today's (true, true) behavior. Exposed via an
optional query parameter `?mode=lite|full` on the JM/TM thread-dump
endpoints.
- Add config cluster.thread-dump.default-mode (default FULL to preserve
upgrade behavior; LITE recommended for large clusters).
- Add a Lite/Full toggle to both Web UI thread-dump pages; selecting a
mode does not auto-fetch, the download link tracks the selection.
be8a20c to
00cef73
Compare
Myasuka
left a comment
There was a problem hiding this comment.
Please take a look at my comments.
| "The maximum stacktrace depth of TaskManager and JobManager's thread dump web-frontend displayed."); | ||
|
|
||
| @Documentation.Section(Documentation.Sections.EXPERT_CLUSTER) | ||
| public static final ConfigOption<String> THREAD_DUMP_DEFAULT_MODE = |
There was a problem hiding this comment.
THREAD_DUMP_DEFAULT_MODE is declared as .stringType() with a default of "FULL", and the actual parsing happens later in ThreadDumpMode.fromStringOrDefault, which silently falls back to FULL for any null/blank/unrecognized value.
That fallback behavior is risky specifically for this option: if an operator mistypes the value (e.g. "Ltie"), the config loads without error and the operator has no indication their setting was ignored — the cluster silently keeps using FULL, the exact high-risk mode this PR is meant to let people opt out of.
Could we either:
- Switch this to
ConfigOptions.key(...).enumType(ThreadDumpMode.class)so invalid values fail fast at config-load time instead of being silently swallowed, or - If we want to keep it as a free-form string (e.g. for forward compatibility), at least log a
WARNinfromStringOrDefault/resolvewhen the configured value doesn't match a knownThreadDumpMode, so this misconfiguration is visible in the logs.
Option 1 seems preferable given ThreadDumpMode is a fixed, closed set of values.
What is the purpose of the change
Fixes FLINK-39984. Clicking "Thread Dump" on a JobManager or TaskManager in the Web UI can cause the targeted process to miss heartbeats and be marked dead by the JobManager, taking down otherwise healthy running jobs.
The dominant cost is not the RPC dispatch but the underlying JVM safepoint:
JvmUtils#createThreadDumpunconditionally callsThreadMXBean.dumpAllThreads(true, true), which requires walking every thread's locked-monitor and j.u.c. synchronizer state inside a single JVM-wide safepoint. On JVMs with many threads (Netty + RocksDB + async I/O + user threads — 10k+ in production is not uncommon) this pauses the entire JVM (including the heartbeat dispatcher) for seconds to tens of seconds. If the pause exceedsheartbeat.timeout(default 50 s), the JM triggers an unnecessary TaskManager failover on what was intended as a purely diagnostic action.This PR makes the dump granularity configurable so operators can pick a mode whose safepoint pause is bounded well
below heartbeat.timeout. A companion PR under the same JIRA additionally offloads the dump construction to
ioExecutor so the RPC mailbox no longer stalls behind the dump; the two fixes are complementary but independent.
Brief change log
ResourceManagerGateway / TaskExecutorGatewayDecoratorBase / NonLeaderRetrievalRestfulGateway.
/jobmanager/thread-dumpand/taskmanagers/{id}/thread-dumpvia a new ThreadDumpModeQueryParameter and two new MessageParameters classes; unknown values become HTTP 400.cluster.thread-dump.default-mode (default FULL)that controls the fallback when no query parameter is supplied. Default is deliberately FULL to preserve the existing on-upgrade behavior; the description flags LITE as the recommended value for large clusters. A separate dev@ discussion will decide whether to flip the default in a future release.(flink-runtime-web/web-dashboard/.../{job,task}-manager/thread-dump/). Selecting a mode does not auto-fetch; the user must press the refresh button (avoids surprising the operator when they merely click the toggle). The download link tracks the current selection so exported dumps match the on-screen content.
Verifying this change
This change added tests and can be verified as follows:
New unit tests
unknown value → IllegalArgumentException, and lower-case serialization.
non-empty dump for null, LITE, and FULL, and (b) when mode is omitted the request honors
cluster.thread-dump.default-mode (the test overrides it to LITE and asserts the "Number of locked synchronizers"
section is absent, which only appears in FULL).
Existing tests updated
ThreadDumpMode parameter.
against the updated snapshot.
Does this pull request potentially affect one of the following parts:
@Public(Evolving): norequest no longer blocks the RPC mailbox and when the operator selects LITE, the
safepoint pause is short enough not to trip heartbeat.timeout.)
Documentation
cluster.thread-dump.default-modeconfig option.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Opus 4.7)